package com.TheyChat.service.config.core.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.TheyChat.service.config.core.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户分类枚举类
 */
@AllArgsConstructor
@Getter
public enum UserTypeEnum implements BaseEnum {
    /**
     * 普通用户
     */
    Normal(0, "普通用户"),
    /**
     * 管理员
     */
    Admin(1, "管理员"),
    /**
     *客服
     * */
    SuperAdmin(2,"超级管理员");

    /**
     *客服
     * */
//    ServiceAgent(3, "客服");


    @EnumValue
    private final Integer value;

    @Getter
    private final String desc;

    /**
     * 序列化
     *
     * @return 不允许返回 null
     */
    @Override
    public Integer getValue() {
        return this.value;
    }

    @JsonCreator
    public static UserTypeEnum create(Integer value) {
        for (UserTypeEnum item : UserTypeEnum.values()) {
            if (item.value.equals(value)) {
                return item;
            }
        }
        throw new BusinessException("Incorrect enum value for UserTypeEnum: " + value);
    }

    public static void main(String[] args) {
        System.out.println(UserTypeEnum.SuperAdmin.value);
    }
}
